home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9594 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  40 lines

  1. Newsgroups: comp.lang.c++
  2. Path: nntp.coast.net!torn!nott!emr1!jagrant
  3. From: jagrant@emr1.emr.ca (John Grant)
  4. Subject: Re: Where do I put inline functions?
  5. Message-ID: <Dnnyxs.Fpu@emr1.emr.ca>
  6. Organization: Energy, Mines, and Resources, Ottawa
  7. References: <4h7sj0$10a@mother.usf.edu> <4ha0bb$297@aphex.direct.ca>
  8. Date: Sat, 2 Mar 1996 23:37:04 GMT
  9.  
  10. In article <4ha0bb$297@aphex.direct.ca> qjackson@direct.ca writes:
  11. >millert@grad.csee.usf.edu (Timothy Miller) wrote:
  12. >
  13. >>Should I put inline functions in .cpp files like normal functions or in 
  14. >>.hpp files like #defines would be in C?
  15. >
  16. >"Should" is a dangerous word when it comes to programming.... ;-)
  17. >
  18. >A tolerable place to put them is in the .hpp file with the class
  19. >definition, since they will be needed by the compiler for any file
  20. >that includes the .hpp.  (A bad place to put them would be the .cpp,
  21.                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  22. >since they are compiled only once and then are no longer visible to
  23. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  24. >the compiler -- how can the compiler include them inline?)
  25. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  26.  
  27.     [...some ideas...]
  28.  
  29.     Then why does the compile accept 'inline' in the class
  30.     definition if it can't find the body of the function (which
  31.     might be in the .cpp file)?
  32.  
  33.     If it is meaningless, the compiler should say something like:
  34.     "inline is only valid if the function code is supplied at the
  35.      same time"
  36. -- 
  37. John A. Grant                        jagrant@emr1.emr.ca
  38. Airborne Geophysics
  39. Geological Survey of Canada, Ottawa
  40.